package com.test.controller;

import com.test.model.Tree;
import com.test.service.TreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("tree")
public class TreeController {

    @Autowired
    private TreeService treeService;

    @GetMapping("test01")
    public String test01() {
        return "tree/test01";
    }

    @GetMapping("getTree")
    @ResponseBody
    public Map<String, Object> getTree() {
        List<Tree> list = treeService.getTree();
        Map<String, Object> data = new HashMap<>();
        data.put("data", list);

        return data;
    }
}
